
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.8.6 动作通信实现 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="387-can-shu-fu-wu-an-li-fen-xi.html" />
    
    
    <link rel="prev" href="385-dong-zuo-tong-xin-an-li-fen-xi.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    课程简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../chapter1.html">
            
                <a href="../../chapter1.html">
            
                    
                    第1章 ROS2概述与环境搭建
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../chapter1/11-ros2jian-jie.html">
            
                <a href="../../chapter1/11-ros2jian-jie.html">
            
                    
                    1.1 ROS2简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="../../chapter1/11-ros2jian-jie/111-ros2fa-zhan-li-cheng.html">
            
                <a href="../../chapter1/11-ros2jian-jie/111-ros2fa-zhan-li-cheng.html">
            
                    
                    1.1.1 ROS2发展历程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.2" data-path="../../chapter1/11-ros2jian-jie/112-ros2zu-cheng-ti-xi.html">
            
                <a href="../../chapter1/11-ros2jian-jie/112-ros2zu-cheng-ti-xi.html">
            
                    
                    1.1.2 ROS2组成体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.3" data-path="../../chapter1/11-ros2jian-jie/113-ros2you-shi.html">
            
                <a href="../../chapter1/11-ros2jian-jie/113-ros2you-shi.html">
            
                    
                    1.1.3 ROS2优势
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../chapter1/12-ros2an-zhuang.html">
            
                <a href="../../chapter1/12-ros2an-zhuang.html">
            
                    
                    1.2 ROS2安装
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../../chapter1/12-ros2an-zhuang/121-an-zhuang-ros2.html">
            
                <a href="../../chapter1/12-ros2an-zhuang/121-an-zhuang-ros2.html">
            
                    
                    1.2.1 安装ROS2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../../chapter1/12-ros2an-zhuang/122-ce-shi-ros2.html">
            
                <a href="../../chapter1/12-ros2an-zhuang/122-ce-shi-ros2.html">
            
                    
                    1.2.2 测试ROS2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.3" data-path="../../chapter1/12-ros2an-zhuang/123-an-zhuang-ros2-gou-jian-gong-ju.html">
            
                <a href="../../chapter1/12-ros2an-zhuang/123-an-zhuang-ros2-gou-jian-gong-ju.html">
            
                    
                    1.2.3 安装colcon构建工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../chapter1/13-ros2kuai-su-ti-yan.html">
            
                <a href="../../chapter1/13-ros2kuai-su-ti-yan.html">
            
                    
                    1.3 ROS2快速体验
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.3.1" data-path="../../chapter1/13-ros2kuai-su-ti-yan/131.html">
            
                <a href="../../chapter1/13-ros2kuai-su-ti-yan/131.html">
            
                    
                    1.3.1 案例简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.2" data-path="../../chapter1/13-ros2kuai-su-ti-yan/131-helloworldcshi-73b029.html">
            
                <a href="../../chapter1/13-ros2kuai-su-ti-yan/131-helloworldcshi-73b029.html">
            
                    
                    1.3.2 HelloWorld（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.3" data-path="../../chapter1/13-ros2kuai-su-ti-yan/132-helloworldpythonshi-73b029.html">
            
                <a href="../../chapter1/13-ros2kuai-su-ti-yan/132-helloworldpythonshi-73b029.html">
            
                    
                    1.3.3 HelloWorld（Python）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.4" data-path="../../chapter1/13-ros2kuai-su-ti-yan/134-yun-xing-you-hua.html">
            
                <a href="../../chapter1/13-ros2kuai-su-ti-yan/134-yun-xing-you-hua.html">
            
                    
                    1.3.4 运行优化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian.html">
            
                <a href="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian.html">
            
                    
                    1.4 ROS2集成开发环境搭建
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.4.1" data-path="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian/141-an-zhuang-vscode.html">
            
                <a href="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian/141-an-zhuang-vscode.html">
            
                    
                    1.4.1 安装VSCode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.2" data-path="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian/142-an-zhuang-zhong-duan.html">
            
                <a href="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian/142-an-zhuang-zhong-duan.html">
            
                    
                    1.4.2 安装终端
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4.3" data-path="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian/143-an-zhuang-git.html">
            
                <a href="../../chapter1/14-ros2ji-cheng-kai-fa-huan-jing-da-jian/143-an-zhuang-git.html">
            
                    
                    1.4.3 安装git
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../../chapter1/15-ros2ti-xi-kuang-jia.html">
            
                <a href="../../chapter1/15-ros2ti-xi-kuang-jia.html">
            
                    
                    1.5 ROS2体系框架
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.5.1" data-path="../../chapter1/15-ros2ti-xi-kuang-jia/151-ros2wen-jian-xi-tong.html">
            
                <a href="../../chapter1/15-ros2ti-xi-kuang-jia/151-ros2wen-jian-xi-tong.html">
            
                    
                    1.5.1 ROS2文件系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5.2" data-path="../../chapter1/15-ros2ti-xi-kuang-jia/153-xue-xi-mo-kuai.html">
            
                <a href="../../chapter1/15-ros2ti-xi-kuang-jia/153-xue-xi-mo-kuai.html">
            
                    
                    1.5.2 ROS2核心模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5.3" data-path="../../chapter1/15-ros2ti-xi-kuang-jia/153-ros2jie-shu-zhi-chi.html">
            
                <a href="../../chapter1/15-ros2ti-xi-kuang-jia/153-ros2jie-shu-zhi-chi.html">
            
                    
                    1.5.3 ROS2技术支持
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5.4" data-path="../../chapter1/15-ros2ti-xi-kuang-jia/154-ros2jie-mei-zu-zhi.html">
            
                <a href="../../chapter1/15-ros2ti-xi-kuang-jia/154-ros2jie-mei-zu-zhi.html">
            
                    
                    1.5.4 ROS2应用方向
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../../chapter1/16-ben-zhang-xiao-jie.html">
            
                <a href="../../chapter1/16-ben-zhang-xiao-jie.html">
            
                    
                    1.6 本章小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin.html">
            
                    
                    第2章 ROS2通信机制核心
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/21-jie-kou-xiao-xi.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/21-jie-kou-xiao-xi.html">
            
                    
                    2.1 通信机制简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin.html">
            
                    
                    2.2 话题通信
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.2.1" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/221-hua-ti-tong-xin-an-li-fen-xi.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/221-hua-ti-tong-xin-an-li-fen-xi.html">
            
                    
                    2.2.1 案例以及案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.2" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/222-hua-ti-tong-xin-c-shi-73b028-yuan-sheng-xiao-606f29.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/222-hua-ti-tong-xin-c-shi-73b028-yuan-sheng-xiao-606f29.html">
            
                    
                    2.2.2 话题通信之原生消息（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.3" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/223-hua-ti-tong-xin-python-shi-73b028-yuan-sheng-xiao-606f29.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/223-hua-ti-tong-xin-python-shi-73b028-yuan-sheng-xiao-606f29.html">
            
                    
                    2.2.3 话题通信之原生消息（Python）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.4" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/222-hua-ti-tong-xin-jie-kou-xiao-xi.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/222-hua-ti-tong-xin-jie-kou-xiao-xi.html">
            
                    
                    2.2.4 话题通信自定义接口消息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.5" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/223-hua-ti-tong-xin-c-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/223-hua-ti-tong-xin-c-shi-xian.html">
            
                    
                    2.2.5 话题通信之自定义消息（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.6" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/224-hua-ti-tong-xin-python-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/22-hua-ti-tong-xin/224-hua-ti-tong-xin-python-shi-xian.html">
            
                    
                    2.2.6 话题通信之自定义消息（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin.html">
            
                    
                    2.3 服务通信
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/231-fu-wu-tong-xin-li-lun-mo-xing.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/231-fu-wu-tong-xin-li-lun-mo-xing.html">
            
                    
                    2.3.1 案例以及案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/232-hua-ti-tong-xin-jie-kou-xiao-xi.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/232-hua-ti-tong-xin-jie-kou-xiao-xi.html">
            
                    
                    2.3.2 服务通信接口消息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.3" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/233-fu-wu-tong-xin-c-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/233-fu-wu-tong-xin-c-shi-xian.html">
            
                    
                    2.3.3 服务通信（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.4" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/234-fu-wu-tong-xin-python-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/23-fu-wu-tong-xin/234-fu-wu-tong-xin-python-shi-xian.html">
            
                    
                    2.3.4 服务通信（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin.html">
            
                    
                    2.4 动作通信
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.1" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/241-dong-zuo-tong-xin-li-lun-mo-xing.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/241-dong-zuo-tong-xin-li-lun-mo-xing.html">
            
                    
                    2.4.1 案例以及案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/242-dong-zuo-tong-xin-jie-kou-xiao-xi.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/242-dong-zuo-tong-xin-jie-kou-xiao-xi.html">
            
                    
                    2.4.2 动作通信接口消息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.3" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/243-dong-zuo-tong-xin-c-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/243-dong-zuo-tong-xin-c-shi-xian.html">
            
                    
                    2.4.3 动作通信（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.4" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/244-dong-zuo-tong-xin-python-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/24-dong-zuo-tong-xin/244-dong-zuo-tong-xin-python-shi-xian.html">
            
                    
                    2.4.4 动作通信（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu.html">
            
                    
                    2.5 参数服务
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/251-can-shu-fu-wu-li-lun-mo-xing.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/251-can-shu-fu-wu-li-lun-mo-xing.html">
            
                    
                    2.5.1 案例以及案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.2" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/252-can-shu-shu-ju-lei-xing.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/252-can-shu-shu-ju-lei-xing.html">
            
                    
                    2.5.2 参数数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.3" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/253-can-shu-fu-wu-c-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/253-can-shu-fu-wu-c-shi-xian.html">
            
                    
                    2.5.3 参数服务（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.4" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/254-can-shu-fu-wu-python-shi-xian.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/25-can-shu-fu-wu/254-can-shu-fu-wu-python-shi-xian.html">
            
                    
                    2.5.4 参数服务（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/28-ben-zhang-xiao-jie.html">
            
                <a href="../../di-2-zhang-ros2-tong-xin-ji-zhi-he-xin/28-ben-zhang-xiao-jie.html">
            
                    
                    2.6 本章小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong.html">
            
                <a href="../../di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong.html">
            
                    
                    第3章 ROS2通信机制补充
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../31-fen-bu-shi.html">
            
                <a href="../31-fen-bu-shi.html">
            
                    
                    3.1 分布式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../32-gong-zuo-kong-jian-fu-gai.html">
            
                <a href="../32-gong-zuo-kong-jian-fu-gai.html">
            
                    
                    3.2 工作空间覆盖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../33-yuan-gong-neng-bao.html">
            
                <a href="../33-yuan-gong-neng-bao.html">
            
                    
                    3.3 元功能包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../34-jie-dian-zhong-ming.html">
            
                <a href="../34-jie-dian-zhong-ming.html">
            
                    
                    3.4 节点重名
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.4.1" data-path="../34-jie-dian-zhong-ming/341-rou-si.html">
            
                <a href="../34-jie-dian-zhong-ming/341-rou-si.html">
            
                    
                    3.4.1 ros2 run设置节点名称
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4.2" data-path="../34-jie-dian-zhong-ming/342-launch-wen-jian-jie-jue-jie-dian-zhong-ming-wen-ti.html">
            
                <a href="../34-jie-dian-zhong-ming/342-launch-wen-jian-jie-jue-jie-dian-zhong-ming-wen-ti.html">
            
                    
                    3.4.2 launch文件设置节点名称
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4.3" data-path="../34-jie-dian-zhong-ming/343-bian-ma-jie-jue-jie-dian-zhong-ming-wen-ti.html">
            
                <a href="../34-jie-dian-zhong-ming/343-bian-ma-jie-jue-jie-dian-zhong-ming-wen-ti.html">
            
                    
                    3.4.3 编码设置节点名称
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../35-hua-ti-zhong-ming.html">
            
                <a href="../35-hua-ti-zhong-ming.html">
            
                    
                    3.5 话题重名
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.5.1" data-path="../35-hua-ti-zhong-ming/351-ros2-run-xiu-gai-hua-ti-ming-cheng.html">
            
                <a href="../35-hua-ti-zhong-ming/351-ros2-run-xiu-gai-hua-ti-ming-cheng.html">
            
                    
                    3.5.1 ros2 run设置话题名称
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5.2" data-path="../35-hua-ti-zhong-ming/352-launch-wen-jian-xiu-gai-hua-ti-ming-cheng.html">
            
                <a href="../35-hua-ti-zhong-ming/352-launch-wen-jian-xiu-gai-hua-ti-ming-cheng.html">
            
                    
                    3.5.2 launch文件设置话题名称
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5.3" data-path="../35-hua-ti-zhong-ming/353-bian-ma-she-zhi-hua-ti-ming-cheng.html">
            
                <a href="../35-hua-ti-zhong-ming/353-bian-ma-she-zhi-hua-ti-ming-cheng.html">
            
                    
                    3.5.3 编码设置话题名称
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../36-chang-yong-api.html">
            
                <a href="../36-chang-yong-api.html">
            
                    
                    3.6 时间相关API
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.6.1" data-path="../36-chang-yong-api/361-rate.html">
            
                <a href="../36-chang-yong-api/361-rate.html">
            
                    
                    3.6.1 Rate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6.2" data-path="../36-chang-yong-api/362-time.html">
            
                <a href="../36-chang-yong-api/362-time.html">
            
                    
                    3.6.2 Time
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6.3" data-path="../36-chang-yong-api/363-duration.html">
            
                <a href="../36-chang-yong-api/363-duration.html">
            
                    
                    3.6.3 Duration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6.4" data-path="../36-chang-yong-api/364-time-yu-duration-yun-suan.html">
            
                <a href="../36-chang-yong-api/364-time-yu-duration-yun-suan.html">
            
                    
                    3.6.4 Time 与 Duration 运算
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../37-tong-xin-ji-zhi-ming-ling.html">
            
                <a href="../37-tong-xin-ji-zhi-ming-ling.html">
            
                    
                    3.7 通信机制工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.7.1" data-path="../37-tong-xin-ji-zhi-ming-ling/371-ming-ling-gong-ju.html">
            
                <a href="../37-tong-xin-ji-zhi-ming-ling/371-ming-ling-gong-ju.html">
            
                    
                    3.7.1 命令工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.2" data-path="../37-tong-xin-ji-zhi-ming-ling/372-rqtgong-ju-xiang.html">
            
                <a href="../37-tong-xin-ji-zhi-ming-ling/372-rqtgong-ju-xiang.html">
            
                    
                    3.7.2 rqt工具箱
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../38-tong-xin-ji-zhi-lian-xi.html">
            
                <a href="../38-tong-xin-ji-zhi-lian-xi.html">
            
                    
                    3.8 通信机制实操
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.8.1" data-path="381-hua-ti-tong-xin-lian-xi.html">
            
                <a href="381-hua-ti-tong-xin-lian-xi.html">
            
                    
                    3.8.1 话题通信案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.2" data-path="382-fu-wu-tong-xin-lian-xi.html">
            
                <a href="382-fu-wu-tong-xin-lian-xi.html">
            
                    
                    3.8.2 话题通信实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.3" data-path="383-dong-zuo-tong-xin-lian-xi.html">
            
                <a href="383-dong-zuo-tong-xin-lian-xi.html">
            
                    
                    3.8.3 服务通信案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.4" data-path="384-can-shu-fu-wu-lian-xi.html">
            
                <a href="384-can-shu-fu-wu-lian-xi.html">
            
                    
                    3.8.4 服务通信实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.5" data-path="385-dong-zuo-tong-xin-an-li-fen-xi.html">
            
                <a href="385-dong-zuo-tong-xin-an-li-fen-xi.html">
            
                    
                    3.8.5 动作通信案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.8.6" data-path="386-dong-zuo-tong-xin-shi-xian.html">
            
                <a href="386-dong-zuo-tong-xin-shi-xian.html">
            
                    
                    3.8.6 动作通信实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.7" data-path="387-can-shu-fu-wu-an-li-fen-xi.html">
            
                <a href="387-can-shu-fu-wu-an-li-fen-xi.html">
            
                    
                    3.8.7 参数服务案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.8" data-path="388-can-shu-fu-wu-shi-xian.html">
            
                <a href="388-can-shu-fu-wu-shi-xian.html">
            
                    
                    3.8.8 参数服务实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../39-ben-zhang-xiao-jie.html">
            
                <a href="../39-ben-zhang-xiao-jie.html">
            
                    
                    3.9 本章小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt.html">
            
                    
                    第4章 ROS2工具之launch与rosbag2
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/41-launch-jian-jie.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/41-launch-jian-jie.html">
            
                    
                    4.1 启动文件launch简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/41-launch-jian-jie/411-launch-ji-ben-shi-yong-liu-cheng.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/41-launch-jian-jie/411-launch-ji-ben-shi-yong-liu-cheng.html">
            
                    
                    4.1.1 launch 基本使用流程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian.html">
            
                    
                    4.2 launch之Python实现
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.2.1" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/421-jie-dian-she-zhi.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/421-jie-dian-she-zhi.html">
            
                    
                    4.2.1 节点设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.2" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/422-zhi-xing-ming-ling.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/422-zhi-xing-ming-ling.html">
            
                    
                    4.2.2 执行指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.3" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/424-wen-jian-bao-han.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/424-wen-jian-bao-han.html">
            
                    
                    4.2.3 参数设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.4" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/425-wen-jian-bao-han.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/425-wen-jian-bao-han.html">
            
                    
                    4.2.4 文件包含
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.5" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/426-fen-zu-she-zhi.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/426-fen-zu-she-zhi.html">
            
                    
                    4.2.5 分组设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.6" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/423-tian-jia-shi-jian.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/42-launchzhi-python-shi-xian/423-tian-jia-shi-jian.html">
            
                    
                    4.2.6 添加事件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian.html">
            
                    
                    4.3 launch之xml、yaml实现
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.3.1" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/431-jie-dian-she-zhi.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/431-jie-dian-she-zhi.html">
            
                    
                    4.3.1 节点设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3.2" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/432-zhi-xing-zhi-ling.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/432-zhi-xing-zhi-ling.html">
            
                    
                    4.3.2 执行指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3.3" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/433-can-shu-she-zhi.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/433-can-shu-she-zhi.html">
            
                    
                    4.3.3 参数设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3.4" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/434-wen-jian-bao-han.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/434-wen-jian-bao-han.html">
            
                    
                    4.3.4 文件包含
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3.5" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/435-fen-zu-she-zhi.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/43-launchzhi-xml-shi-xian/435-fen-zu-she-zhi.html">
            
                    
                    4.3.5 分组设置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2.html">
            
                    
                    4.4 录制回放工具——rosbag2
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.4.1" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2/441-ros2-bag-ming-ling-gong-ju.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2/441-ros2-bag-ming-ling-gong-ju.html">
            
                    
                    4.4.1 ros2 bag 命令工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4.2" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2/442-rosbag2-zhi-c-shi-xian.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2/442-rosbag2-zhi-c-shi-xian.html">
            
                    
                    4.4.2 rosbag2 编程（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4.3" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2/443-rosbag2-zhi-python-shi-xian.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/44-rosbag2/443-rosbag2-zhi-python-shi-xian.html">
            
                    
                    4.4.3 rosbag2 编程（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/46-ben-zhang-xiao-jie.html">
            
                <a href="../../di-4-zhang-ros2-gong-ju-zhi-launch-rosbag2-yu-rqt/46-ben-zhang-xiao-jie.html">
            
                    
                    4.5 本章小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan.html">
            
                    
                    第5章 ROS2工具之坐标变换
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/51-zuo-biao-bian-huan-jian-jie.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/51-zuo-biao-bian-huan-jian-jie.html">
            
                    
                    5.1 坐标变换简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1.1" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/51-zuo-biao-bian-huan-jian-jie/511-an-li-an-zhuang-yi-ji-yun-xing.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/51-zuo-biao-bian-huan-jian-jie/511-an-li-an-zhuang-yi-ji-yun-xing.html">
            
                    
                    5.1.1 案例安装以及运行
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/52-zuo-biao-xiao-xi.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/52-zuo-biao-xiao-xi.html">
            
                    
                    5.2 坐标相关消息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo.html">
            
                    
                    5.3 坐标变换广播
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.3.1" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/531-jing-tai-zuo-biao-xi-guan-xi-guang-bo.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/531-jing-tai-zuo-biao-xi-guan-xi-guang-bo.html">
            
                    
                    5.3.1 坐标系广播案例以及分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.2" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/532-jing-tai-guang-bo-qi-ff08-ming-ling-ff09.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/532-jing-tai-guang-bo-qi-ff08-ming-ling-ff09.html">
            
                    
                    5.3.2 静态广播器（命令）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.3" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/533-jing-tai-guang-bo-qi-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/533-jing-tai-guang-bo-qi-ff08-c-++.html">
            
                    
                    5.3.3 静态广播器（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.4" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/534-jing-tai-guang-bo-qi-ff08-python.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/534-jing-tai-guang-bo-qi-ff08-python.html">
            
                    
                    5.3.4 静态广播器（Python）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.5" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/535-dong-tai-guang-bo-qi-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/535-dong-tai-guang-bo-qi-ff08-c-++.html">
            
                    
                    5.3.5 动态广播器（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.6" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/536-dong-tai-guang-bo-qi-ff08-python.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/536-dong-tai-guang-bo-qi-ff08-python.html">
            
                    
                    5.3.6 动态广播器（Python）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.7" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/537-zuo-biao-dian-fa-bu-an-li-fen-xi.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/537-zuo-biao-dian-fa-bu-an-li-fen-xi.html">
            
                    
                    5.3.7 坐标点发布案例以及分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.8" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/538-zuo-biao-dian-fa-bu-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/538-zuo-biao-dian-fa-bu-ff08-c-++.html">
            
                    
                    5.3.8 坐标点发布（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.9" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/539-zuo-biao-dian-fa-bu-ff08-python.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/53-zuo-biao-xi-guang-bo/539-zuo-biao-dian-fa-bu-ff08-python.html">
            
                    
                    5.3.9 坐标点发布（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting.html">
            
                    
                    5.4 坐标变换监听
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.4.1" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/541-zuo-biao-xi-bian-huan.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/541-zuo-biao-xi-bian-huan.html">
            
                    
                    5.4.1 坐标系变换案例以及分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.2" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/542-zuo-biao-dian-bian-huan.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/542-zuo-biao-dian-bian-huan.html">
            
                    
                    5.4.2 坐标系变换（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.3" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/543-zuo-biao-xi-bian-huan-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/543-zuo-biao-xi-bian-huan-ff08-c-++.html">
            
                    
                    5.4.3 坐标系变换（Python）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.4" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/544-zuo-biao-dian-bian-huan-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/544-zuo-biao-dian-bian-huan-ff08-c-++.html">
            
                    
                    5.4.4 坐标点变换（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.5" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/545-zuo-biao-dian-bian-huan-ff08-python.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/54-zuo-biao-xi-jian-ting/545-zuo-biao-dian-bian-huan-ff08-python.html">
            
                    
                    5.4.5 坐标点变换（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/55-tfgong-ju.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/55-tfgong-ju.html">
            
                    
                    5.5 坐标变换工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao.html">
            
                    
                    5.6 坐标变换实操
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.6.1" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/561-wu-gui-gen-sui-an-li-yi-ji-an-li-fen-xi.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/561-wu-gui-gen-sui-an-li-yi-ji-an-li-fen-xi.html">
            
                    
                    5.6.1 乌龟跟随案例以及分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6.2" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/562-wu-gui-gen-sui-shi-xian-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/562-wu-gui-gen-sui-shi-xian-ff08-c-++.html">
            
                    
                    5.6.2 乌龟跟随实现（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6.3" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/563-wu-gui-gen-sui-shi-xian-ff08-python.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/563-wu-gui-gen-sui-shi-xian-ff08-python.html">
            
                    
                    5.6.3 乌龟跟随实现（Python）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6.4" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/562-wu-gui-hu-hang-an-li-yi-ji-fen-xi.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/562-wu-gui-hu-hang-an-li-yi-ji-fen-xi.html">
            
                    
                    5.6.4 乌龟护航案例以及分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6.5" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/565-wu-gui-hu-hang-shi-xian-ff08-c-++.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/565-wu-gui-hu-hang-shi-xian-ff08-c-++.html">
            
                    
                    5.6.5 乌龟护航实现（C++）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6.6" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/566-wu-gui-hu-hang-shi-xian-ff08-python.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/56-zuo-biao-bian-huan-shi-cao/566-wu-gui-hu-hang-shi-xian-ff08-python.html">
            
                    
                    5.6.6 乌龟护航实现（Python）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/57-ben-zhang-xiao-jie.html">
            
                <a href="../../di-5-zhang-ros2-gong-ju-zhi-zuo-biao-bian-huan/57-ben-zhang-xiao-jie.html">
            
                    
                    5.7 本章小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen.html">
            
                    
                    第6章 ROS2工具之可视化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/61-gai-shu.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/61-gai-shu.html">
            
                    
                    6.1 可视化简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/62-rviz2-ji-ben-shi-yong.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/62-rviz2-ji-ben-shi-yong.html">
            
                    
                    6.2 rviz2 基本使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/63-urdfji-cheng-rviz2-ji-ben-liu-cheng.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/63-urdfji-cheng-rviz2-ji-ben-liu-cheng.html">
            
                    
                    6.3 rviz2集成URDF基本流程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.3.1" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/63-urdfji-cheng-rviz2-ji-ben-liu-cheng/631-an-li-yi-ji-an-li-fen-xi.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/63-urdfji-cheng-rviz2-ji-ben-liu-cheng/631-an-li-yi-ji-an-li-fen-xi.html">
            
                    
                    6.3.1 案例以及案例分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.2" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/63-urdfji-cheng-rviz2-ji-ben-liu-cheng/632-an-li-shi-xian.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/63-urdfji-cheng-rviz2-ji-ben-liu-cheng/632-an-li-shi-xian.html">
            
                    
                    6.3.2 案例实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa.html">
            
                    
                    6.4 URDF使用语法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.4.1" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/641-urdfyu-fa-01-robot.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/641-urdfyu-fa-01-robot.html">
            
                    
                    6.4.1 URDF语法01_robot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4.2" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/642-urdfyu-fa-02-link.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/642-urdfyu-fa-02-link.html">
            
                    
                    6.4.2 URDF语法02_link
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4.3" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/643-urdfyu-fa-03-joint.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/643-urdfyu-fa-03-joint.html">
            
                    
                    6.4.3 URDF语法03_joint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4.4" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/644-urdflian-xi.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/644-urdflian-xi.html">
            
                    
                    6.4.4 URDF练习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4.5" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/645-urdfgong-ju.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/64-urdfyu-fa/645-urdfgong-ju.html">
            
                    
                    6.4.5 URDF工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro.html">
            
                    
                    6.5 URDF优化_xacro
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.5.1" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro/651-xacrokuai-su-ti-yan.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro/651-xacrokuai-su-ti-yan.html">
            
                    
                    6.5.1 xacro_快速体验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5.2" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro/652-xacroshi-yong-yu-fa.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro/652-xacroshi-yong-yu-fa.html">
            
                    
                    6.5.2 xacro_使用语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5.3" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro/653-xacroshi-yong-shi-li.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/65-urdfyou-hua-xacro/653-xacroshi-yong-shi-li.html">
            
                    
                    6.5.3 xacro_练习
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/66-ben-zhang-xiao-jie.html">
            
                <a href="../../di-6-zhang-ros2-ji-qi-ren-jian-mo-yu-fang-zhen/66-ben-zhang-xiao-jie.html">
            
                    
                    6.6 本章小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >3.8.6 动作通信实现</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="386-&#x52A8;&#x4F5C;&#x901A;&#x4FE1;&#x5B9E;&#x73B0;">3.8.6 &#x52A8;&#x4F5C;&#x901A;&#x4FE1;&#x5B9E;&#x73B0;</h3>
<h4 id="1&#x52A8;&#x4F5C;&#x63A5;&#x53E3;&#x6587;&#x4EF6;">1.&#x52A8;&#x4F5C;&#x63A5;&#x53E3;&#x6587;&#x4EF6;</h4>
<p>&#x529F;&#x80FD;&#x5305;base_interfaces_demo&#x7684;action&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x65B0;&#x5EFA;action&#x6587;&#x4EF6;Nav.action&#xFF0C;&#x5E76;&#x7F16;&#x8F91;&#x6587;&#x4EF6;&#xFF0C;&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code>float32 goal_x
float32 goal_y
float32 goal_theta
---
float32 turtle_x
float32 turtle_y
float32 turtle_theta
---
float32 distance
</code></pre><h4 id="2&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#x5B9E;&#x73B0;">2.&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#x5B9E;&#x73B0;</h4>
<p>&#x529F;&#x80FD;&#x5305;cpp07_exercise&#x7684;src&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x65B0;&#x5EFA;C++&#x6587;&#x4EF6;exe04_action_server.cpp&#xFF0C;&#x5E76;&#x7F16;&#x8F91;&#x6587;&#x4EF6;&#xFF0C;&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code class="lang-cpp"><span class="hljs-comment">/*
   &#x9700;&#x6C42;&#xFF1A;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#x53D1;&#x9001;&#x7684;&#x76EE;&#x6807;&#x70B9;&#xFF0C;&#x63A7;&#x5236;&#x4E4C;&#x9F9F;&#x5411;&#x8BE5;&#x76EE;&#x6807;&#x70B9;&#x8FD0;&#x52A8;&#xFF0C;&#x5E76;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#x4E4C;&#x9F9F;&#x4E0E;&#x76EE;&#x6807;&#x70B9;&#x4E4B;&#x95F4;&#x7684;&#x5269;&#x4F59;&#x8DDD;&#x79BB;&#x3002;
   &#x6B65;&#x9AA4;&#xFF1A;
       1.&#x5305;&#x542B;&#x5934;&#x6587;&#x4EF6;&#xFF1B;
       2.&#x521D;&#x59CB;&#x5316; ROS2 &#x5BA2;&#x6237;&#x7AEF;&#xFF1B;
       3.&#x5B9A;&#x4E49;&#x8282;&#x70B9;&#x7C7B;&#xFF1B;
            3-1.&#x521B;&#x5EFA;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x4F4D;&#x59FF;&#x8BA2;&#x9605;&#x65B9;&#xFF0C;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x4E2D;&#x83B7;&#x53D6;&#x4E4C;&#x9F9F;&#x4F4D;&#x59FF;&#xFF1B;
            3-2.&#x521B;&#x5EFA;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x901F;&#x5EA6;&#x53D1;&#x5E03;&#x65B9;&#xFF1B;
            3-3.&#x521B;&#x5EFA;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#xFF1B;
            3-4.&#x89E3;&#x6790;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x7684;&#x8BF7;&#x6C42;&#xFF1B;
            3-5.&#x5904;&#x7406;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x7684;&#x53D6;&#x6D88;&#x8BF7;&#x6C42;&#xFF1B;
            3-6.&#x521B;&#x5EFA;&#x65B0;&#x7EBF;&#x7A0B;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#xFF1B;
            3-7.&#x65B0;&#x7EBF;&#x7A0B;&#x4EA7;&#x751F;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#x5E76;&#x54CD;&#x5E94;&#x6700;&#x7EC8;&#x7ED3;&#x679C;&#x3002;
       4.&#x8C03;&#x7528;spin&#x51FD;&#x6570;&#xFF0C;&#x5E76;&#x4F20;&#x5165;&#x8282;&#x70B9;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#xFF1B;
       5.&#x91CA;&#x653E;&#x8D44;&#x6E90;&#x3002;
*/</span>
<span class="hljs-comment">// 1.&#x5305;&#x542B;&#x5934;&#x6587;&#x4EF6;&#xFF1B; </span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;rclcpp/rclcpp.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;rclcpp_action/rclcpp_action.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;base_interfaces_demo/action/nav.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;turtlesim/msg/pose.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;geometry_msgs/msg/twist.hpp&quot;</span></span>

<span class="hljs-keyword">using</span> base_interfaces_demo::action::Nav;
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>::placeholders;

<span class="hljs-comment">// 3.&#x5B9A;&#x4E49;&#x8282;&#x70B9;&#x7C7B;&#xFF1B;</span>
<span class="hljs-keyword">class</span> ExeNavActionServer: <span class="hljs-keyword">public</span> rclcpp::Node {
<span class="hljs-keyword">public</span>:
    ExeNavActionServer(<span class="hljs-keyword">const</span> rclcpp::NodeOptions &amp; options = rclcpp::NodeOptions()):
        Node(<span class="hljs-string">&quot;exe_nav_action_server&quot;</span>,options){
        <span class="hljs-comment">// 3-1.&#x521B;&#x5EFA;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x4F4D;&#x59FF;&#x8BA2;&#x9605;&#x65B9;&#xFF0C;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x4E2D;&#x83B7;&#x53D6;&#x4E4C;&#x9F9F;&#x4F4D;&#x59FF;&#xFF1B;</span>
        pose_sub = <span class="hljs-keyword">this</span>-&gt;create_subscription&lt;turtlesim::msg::Pose&gt;(<span class="hljs-string">&quot;/turtle1/pose&quot;</span>,<span class="hljs-number">10</span>,<span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionServer::poseCallBack, <span class="hljs-keyword">this</span>, <span class="hljs-built_in">std</span>::placeholders::_1));
        <span class="hljs-comment">// 3-2.&#x521B;&#x5EFA;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x901F;&#x5EA6;&#x53D1;&#x5E03;&#x65B9;&#xFF1B;</span>
        cmd_vel_pub = <span class="hljs-keyword">this</span>-&gt;create_publisher&lt;geometry_msgs::msg::Twist&gt;(<span class="hljs-string">&quot;/turtle1/cmd_vel&quot;</span>,<span class="hljs-number">10</span>);
        <span class="hljs-comment">// 3-3.&#x521B;&#x5EFA;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#xFF1B;</span>
        nav_action_server = rclcpp_action::create_server&lt;Nav&gt;(
            <span class="hljs-keyword">this</span>,
            <span class="hljs-string">&quot;nav&quot;</span>,
            <span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionServer::handle_goal,<span class="hljs-keyword">this</span>,_1,_2),
            <span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionServer::handle_cancel,<span class="hljs-keyword">this</span>,_1),
            <span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionServer::handle_accepted,<span class="hljs-keyword">this</span>,_1)
            );

    }
<span class="hljs-keyword">private</span>:
    turtlesim::msg::Pose::SharedPtr turtle1_pose = <span class="hljs-literal">nullptr</span>;
    rclcpp::Subscription&lt;turtlesim::msg::Pose&gt;::SharedPtr pose_sub;
    rclcpp_action::Server&lt;Nav&gt;::SharedPtr nav_action_server;
    rclcpp::Publisher&lt;geometry_msgs::msg::Twist&gt;::SharedPtr cmd_vel_pub;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">poseCallBack</span><span class="hljs-params">(<span class="hljs-keyword">const</span> turtlesim::msg::Pose::SharedPtr pose)</span></span>{
        turtle1_pose = pose;
    }
    <span class="hljs-comment">// 3-4.&#x89E3;&#x6790;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x7684;&#x8BF7;&#x6C42;&#xFF1B;</span>
    rclcpp_action::<span class="hljs-function">GoalResponse <span class="hljs-title">handle_goal</span><span class="hljs-params">(<span class="hljs-keyword">const</span> rclcpp_action::GoalUUID &amp; goal_uuid, <span class="hljs-built_in">std</span>::<span class="hljs-built_in">shared_ptr</span>&lt;<span class="hljs-keyword">const</span> Nav::Goal&gt; goal)</span></span>{
        (<span class="hljs-keyword">void</span>)goal_uuid;
        RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x8BF7;&#x6C42;&#x5750;&#x6807;:(%.2f,%.2f),&#x822A;&#x5411;:%.2f&quot;</span>, goal-&gt;goal_x,goal-&gt;goal_y,goal-&gt;goal_theta);
        <span class="hljs-keyword">if</span> (goal-&gt;goal_x &lt; <span class="hljs-number">0</span> || goal-&gt;goal_x &gt; <span class="hljs-number">11.1</span> || goal-&gt;goal_y &lt; <span class="hljs-number">0</span> || goal-&gt;goal_y &gt; <span class="hljs-number">11.1</span>)
        {
            <span class="hljs-keyword">return</span> rclcpp_action::GoalResponse::REJECT;
        }

        <span class="hljs-keyword">return</span> rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
    }
    <span class="hljs-comment">// 3-5.&#x5904;&#x7406;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x7684;&#x53D6;&#x6D88;&#x8BF7;&#x6C42;&#xFF1B;</span>
    rclcpp_action::<span class="hljs-function">CancelResponse <span class="hljs-title">handle_cancel</span><span class="hljs-params">(<span class="hljs-built_in">std</span>::<span class="hljs-built_in">shared_ptr</span>&lt;rclcpp_action::ServerGoalHandle&lt;Nav&gt;&gt; goal_handle)</span></span>{
        (<span class="hljs-keyword">void</span>)goal_handle;
        RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x4EFB;&#x52A1;&#x53D6;&#x6D88;!&quot;</span>);
        <span class="hljs-keyword">return</span> rclcpp_action::CancelResponse::ACCEPT;
    }
    <span class="hljs-comment">// 3-7.&#x65B0;&#x7EBF;&#x7A0B;&#x4EA7;&#x751F;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#x5E76;&#x54CD;&#x5E94;&#x6700;&#x7EC8;&#x7ED3;&#x679C;&#x3002;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">execute</span><span class="hljs-params">(<span class="hljs-built_in">std</span>::<span class="hljs-built_in">shared_ptr</span>&lt;rclcpp_action::ServerGoalHandle&lt;Nav&gt;&gt; goal_handle)</span></span>{
        RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x4EFB;&#x52A1;......&quot;</span>);
        <span class="hljs-comment">// &#x89E3;&#x6790;&#x76EE;&#x6807;&#x503C;</span>
        <span class="hljs-keyword">float</span> goal_x = goal_handle-&gt;get_goal()-&gt;goal_x;
        <span class="hljs-keyword">float</span> goal_y = goal_handle-&gt;get_goal()-&gt;goal_y;
        <span class="hljs-comment">// &#x521B;&#x5EFA;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#xFF1B;</span>
        <span class="hljs-keyword">auto</span> feedback = <span class="hljs-built_in">std</span>::make_shared&lt;Nav::Feedback&gt;();
        <span class="hljs-comment">// &#x521B;&#x5EFA;&#x6700;&#x7EC8;&#x7ED3;&#x679C;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#xFF1B;</span>
        <span class="hljs-keyword">auto</span> result = <span class="hljs-built_in">std</span>::make_shared&lt;Nav::Result&gt;();

        rclcpp::<span class="hljs-function">Rate <span class="hljs-title">rate</span><span class="hljs-params">(<span class="hljs-number">1.0</span>)</span></span>;
        <span class="hljs-keyword">while</span> (<span class="hljs-literal">true</span>)
        {
            <span class="hljs-comment">// &#x4EFB;&#x52A1;&#x6267;&#x884C;&#x4E2D;&#xFF0C;&#x5173;&#x4E8E;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x53D6;&#x6D88;&#x8BF7;&#x6C42;&#x7684;&#x5904;&#x7406;&#xFF1B;</span>
            <span class="hljs-keyword">if</span>(goal_handle-&gt;is_canceling()){
                goal_handle-&gt;canceled(result);
                <span class="hljs-keyword">return</span>;
            }
            <span class="hljs-comment">// &#x89E3;&#x6790;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x4F4D;&#x59FF;&#x6570;&#x636E;&#xFF1B;</span>
            <span class="hljs-keyword">float</span> turtle1_x = turtle1_pose-&gt;x;
            <span class="hljs-keyword">float</span> turtle1_y = turtle1_pose-&gt;y;
            <span class="hljs-keyword">float</span> turtle1_theta = turtle1_pose-&gt;theta;
            <span class="hljs-comment">// &#x8BA1;&#x7B97;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x4E0E;&#x76EE;&#x6807;&#x4E4C;&#x9F9F;&#x7684;x&#x5411;&#x4EE5;&#x53CA;y&#x5411;&#x8DDD;&#x79BB;&#xFF1B;</span>
            <span class="hljs-keyword">float</span> x_distance = goal_x - turtle1_x;
            <span class="hljs-keyword">float</span> y_distance = goal_y - turtle1_y;


            <span class="hljs-comment">// &#x8BA1;&#x7B97;&#x901F;&#x5EA6;</span>
            geometry_msgs::msg::Twist twist;
            <span class="hljs-keyword">double</span> scale = <span class="hljs-number">0.5</span>;
            twist.linear.x = scale * x_distance;
            twist.linear.y = scale * y_distance;
            cmd_vel_pub-&gt;publish(twist);
            <span class="hljs-comment">// &#x8BA1;&#x7B97;&#x5269;&#x4F59;&#x8DDD;&#x79BB;</span>
            <span class="hljs-keyword">float</span> distance = <span class="hljs-built_in">sqrt</span>(<span class="hljs-built_in">pow</span>(x_distance,<span class="hljs-number">2</span>) + <span class="hljs-built_in">pow</span>(y_distance,<span class="hljs-number">2</span>));

            <span class="hljs-comment">// &#x5F53;&#x4E24;&#x9F9F;&#x8DDD;&#x79BB;&#x5C0F;&#x4E8E;0.15&#x7C73;&#x65F6;&#xFF0C;&#x5C06;&#x5F53;&#x524D;&#x4E4C;&#x9F9F;&#x4F4D;&#x59FF;&#x8BBE;&#x7F6E;&#x8FDB;result&#x5E76;&#x9000;&#x51FA;&#x5FAA;&#x73AF;</span>
            <span class="hljs-keyword">if</span> (distance &lt; <span class="hljs-number">0.15</span>)
            {   
                <span class="hljs-comment">//&#x5C06;&#x5F53;&#x524D;&#x4E4C;&#x9F9F;&#x5750;&#x6807;&#x8D4B;&#x503C;&#x7ED9; result</span>
                result-&gt;turtle_x = turtle1_x;
                result-&gt;turtle_y = turtle1_y;
                result-&gt;turtle_theta = turtle1_theta;
                <span class="hljs-keyword">break</span>;
            }
            <span class="hljs-comment">// &#x4E3A;feedback&#x8BBE;&#x7F6E;&#x6570;&#x636E;&#x5E76;&#x53D1;&#x5E03;</span>
            feedback-&gt;distance = distance;
            goal_handle-&gt;publish_feedback(feedback);

            rate.sleep();
        }
        <span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x6700;&#x7EC8;&#x54CD;&#x5E94;&#x7ED3;&#x679C;</span>
        <span class="hljs-keyword">if</span> (rclcpp::ok())
        {
            goal_handle-&gt;succeed(result);
            RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x4EFB;&#x52A1;&#x7ED3;&#x675F;!&quot;</span>);
        }


    }
    <span class="hljs-comment">// 3-6.&#x521B;&#x5EFA;&#x65B0;&#x7EBF;&#x7A0B;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#xFF1B;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">handle_accepted</span><span class="hljs-params">(<span class="hljs-built_in">std</span>::<span class="hljs-built_in">shared_ptr</span>&lt;rclcpp_action::ServerGoalHandle&lt;Nav&gt;&gt; goal_handle)</span></span>{
        <span class="hljs-built_in">std</span>::thread{<span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionServer::execute,<span class="hljs-keyword">this</span>,_1),goal_handle}.detach();
    }


};

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">char</span> <span class="hljs-keyword">const</span> *argv[])</span>
</span>{
    <span class="hljs-comment">// 2.&#x521D;&#x59CB;&#x5316; ROS2 &#x5BA2;&#x6237;&#x7AEF;&#xFF1B;</span>
    rclcpp::init(argc,argv);
    <span class="hljs-comment">// 4.&#x8C03;&#x7528;spin&#x51FD;&#x6570;&#xFF0C;&#x5E76;&#x4F20;&#x5165;&#x8282;&#x70B9;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#xFF1B;</span>
    rclcpp::spin(<span class="hljs-built_in">std</span>::make_shared&lt;ExeNavActionServer&gt;());
    <span class="hljs-comment">// 5.&#x91CA;&#x653E;&#x8D44;&#x6E90;&#x3002;</span>
    rclcpp::shutdown();
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h4 id="3&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x5B9E;&#x73B0;">3.&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x5B9E;&#x73B0;</h4>
<p>&#x529F;&#x80FD;&#x5305;cpp07_exercise&#x7684;src&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x65B0;&#x5EFA;C++&#x6587;&#x4EF6;exe05_action_client.cpp&#xFF0C;&#x5E76;&#x7F16;&#x8F91;&#x6587;&#x4EF6;&#xFF0C;&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code class="lang-cpp"><span class="hljs-comment">/*
   &#x9700;&#x6C42;&#xFF1A;&#x5411;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#x53D1;&#x9001;&#x76EE;&#x6807;&#x70B9;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x5904;&#x7406;&#x670D;&#x52A1;&#x7AEF;&#x7684;&#x54CD;&#x5E94;&#x6570;&#x636E;&#x3002;
   &#x6B65;&#x9AA4;&#xFF1A;
       1.&#x5305;&#x542B;&#x5934;&#x6587;&#x4EF6;&#xFF1B;
       2.&#x521D;&#x59CB;&#x5316; ROS2 &#x5BA2;&#x6237;&#x7AEF;&#xFF1B;
       3.&#x5B9A;&#x4E49;&#x8282;&#x70B9;&#x7C7B;&#xFF1B;
            3-1.&#x521B;&#x5EFA;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#xFF1B;
            3-2.&#x53D1;&#x9001;&#x8BF7;&#x6C42;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x5904;&#x7406;&#x670D;&#x52A1;&#x7AEF;&#x54CD;&#x5E94;&#xFF1B;
            3-3.&#x5904;&#x7406;&#x76EE;&#x6807;&#x54CD;&#x5E94;&#xFF1B;
            3-4.&#x5904;&#x7406;&#x54CD;&#x5E94;&#x7684;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#xFF1B;
            3-5.&#x5904;&#x7406;&#x6700;&#x7EC8;&#x54CD;&#x5E94;&#x3002;
       4.&#x8C03;&#x7528;spin&#x51FD;&#x6570;&#xFF0C;&#x5E76;&#x4F20;&#x5165;&#x8282;&#x70B9;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#xFF1B;
       5.&#x91CA;&#x653E;&#x8D44;&#x6E90;&#x3002;
*/</span>
<span class="hljs-comment">// 1.&#x5305;&#x542B;&#x5934;&#x6587;&#x4EF6;&#xFF1B;</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;rclcpp/rclcpp.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;rclcpp_action/rclcpp_action.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;base_interfaces_demo/action/nav.hpp&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;turtlesim/srv/spawn.hpp&quot;</span></span>

<span class="hljs-keyword">using</span> base_interfaces_demo::action::Nav;
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>::chrono_literals;
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>::placeholders;

<span class="hljs-comment">// 3.&#x5B9A;&#x4E49;&#x8282;&#x70B9;&#x7C7B;&#xFF1B;</span>
<span class="hljs-keyword">class</span> ExeNavActionClient: <span class="hljs-keyword">public</span> rclcpp::Node{
<span class="hljs-keyword">public</span>:
    ExeNavActionClient(<span class="hljs-keyword">const</span> rclcpp::NodeOptions &amp; options = rclcpp::NodeOptions())
    :Node(<span class="hljs-string">&quot;exe_nav_action_client&quot;</span>,options){
        <span class="hljs-comment">// 3-1.&#x521B;&#x5EFA;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#xFF1B;</span>
        nav_client = rclcpp_action::create_client&lt;Nav&gt;(<span class="hljs-keyword">this</span>,<span class="hljs-string">&quot;nav&quot;</span>);
    }
    <span class="hljs-comment">// 3-2.&#x53D1;&#x9001;&#x8BF7;&#x6C42;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x5904;&#x7406;&#x670D;&#x52A1;&#x7AEF;&#x54CD;&#x5E94;&#xFF1B;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">send_goal</span><span class="hljs-params">(<span class="hljs-keyword">float</span> x, <span class="hljs-keyword">float</span> y, <span class="hljs-keyword">float</span> theta)</span></span>{
        <span class="hljs-comment">// &#x8FDE;&#x63A5;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#xFF0C;&#x5982;&#x679C;&#x8D85;&#x65F6;&#xFF08;5s&#xFF09;&#xFF0C;&#x90A3;&#x4E48;&#x76F4;&#x63A5;&#x9000;&#x51FA;&#x3002;</span>
        <span class="hljs-keyword">if</span> (!nav_client-&gt;wait_for_action_server(<span class="hljs-number">5</span>s))
        {
            RCLCPP_ERROR(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x670D;&#x52A1;&#x8FDE;&#x63A5;&#x5931;&#x8D25;!&quot;</span>);
            <span class="hljs-keyword">return</span>;
        }
        <span class="hljs-comment">// &#x7EC4;&#x7EC7;&#x8BF7;&#x6C42;&#x6570;&#x636E;</span>
        <span class="hljs-keyword">auto</span> goal_msg = Nav::Goal();
        goal_msg.goal_x = x;
        goal_msg.goal_y = y;
        goal_msg.goal_theta = theta;
        <span class="hljs-comment">//const rclcpp_action::Client&lt;base_interfaces_demo::action::Nav&gt;::SendGoalOptions &amp;options</span>
        rclcpp_action::Client&lt;Nav&gt;::SendGoalOptions options;
        options.goal_response_callback = <span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionClient::goal_response_callback, <span class="hljs-keyword">this</span>, _1);
        options.feedback_callback = <span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionClient::feedback_callback, <span class="hljs-keyword">this</span>, _1, _2);
        options.result_callback = <span class="hljs-built_in">std</span>::bind(&amp;ExeNavActionClient::result_callback, <span class="hljs-keyword">this</span>, _1);
        <span class="hljs-comment">// &#x53D1;&#x9001;</span>
        nav_client-&gt;async_send_goal(goal_msg,options);

    }
<span class="hljs-keyword">private</span>:
    rclcpp_action::Client&lt;Nav&gt;::SharedPtr nav_client;
    <span class="hljs-comment">// 3-3.&#x5904;&#x7406;&#x76EE;&#x6807;&#x54CD;&#x5E94;&#xFF1B;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">goal_response_callback</span><span class="hljs-params">(rclcpp_action::ClientGoalHandle&lt;Nav&gt;::SharedPtr goal_handle)</span></span>{
        <span class="hljs-keyword">if</span>(!goal_handle){
            RCLCPP_ERROR(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x76EE;&#x6807;&#x8BF7;&#x6C42;&#x88AB;&#x670D;&#x52A1;&#x5668;&#x62D2;&#x7EDD;&quot;</span>);
        } <span class="hljs-keyword">else</span> {
            RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x76EE;&#x6807;&#x8BF7;&#x6C42;&#x88AB;&#x63A5;&#x6536;!&quot;</span>);
        }
    }
    <span class="hljs-comment">// 3-4.&#x5904;&#x7406;&#x54CD;&#x5E94;&#x7684;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#xFF1B;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">feedback_callback</span><span class="hljs-params">(rclcpp_action::ClientGoalHandle&lt;Nav&gt;::SharedPtr goal_handle, 
        <span class="hljs-keyword">const</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">shared_ptr</span>&lt;<span class="hljs-keyword">const</span> Nav::Feedback&gt; feedback)</span></span>{
        (<span class="hljs-keyword">void</span>)goal_handle;
        RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x8DDD;&#x79BB;&#x76EE;&#x6807;&#x70B9;&#x8FD8;&#x6709; %.2f &#x7C73;&#x3002;&quot;</span>,feedback-&gt;distance);
    }
    <span class="hljs-comment">// 3-5.&#x5904;&#x7406;&#x6700;&#x7EC8;&#x54CD;&#x5E94;&#x3002;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">result_callback</span><span class="hljs-params">(<span class="hljs-keyword">const</span> rclcpp_action::ClientGoalHandle&lt;Nav&gt;::WrappedResult &amp; result)</span></span>{
        <span class="hljs-keyword">switch</span> (result.code){
        <span class="hljs-keyword">case</span> rclcpp_action::ResultCode::SUCCEEDED :
            RCLCPP_INFO(<span class="hljs-keyword">this</span>-&gt;get_logger(),
                <span class="hljs-string">&quot;&#x4E4C;&#x9F9F;&#x6700;&#x7EC8;&#x5750;&#x6807;:(%.2f,%.2f),&#x822A;&#x5411;:%.2f&quot;</span>,
                            result.result-&gt;turtle_x,
                            result.result-&gt;turtle_y,
                            result.result-&gt;turtle_theta
                            );
            <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> rclcpp_action::ResultCode::CANCELED:
            RCLCPP_ERROR(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x4EFB;&#x52A1;&#x88AB;&#x53D6;&#x6D88;&quot;</span>);
            <span class="hljs-keyword">break</span>;      
        <span class="hljs-keyword">case</span> rclcpp_action::ResultCode::ABORTED:
            RCLCPP_ERROR(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x4EFB;&#x52A1;&#x88AB;&#x4E2D;&#x6B62;&quot;</span>);
            <span class="hljs-keyword">break</span>;   
        <span class="hljs-keyword">default</span>:
            RCLCPP_ERROR(<span class="hljs-keyword">this</span>-&gt;get_logger(),<span class="hljs-string">&quot;&#x672A;&#x77E5;&#x5F02;&#x5E38;&quot;</span>);
            <span class="hljs-keyword">break</span>;
        }
        <span class="hljs-comment">// rclcpp::shutdown();</span>
    }
};

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">char</span> <span class="hljs-keyword">const</span> *argv[])</span>
</span>{
    <span class="hljs-comment">// 2.&#x521D;&#x59CB;&#x5316; ROS2 &#x5BA2;&#x6237;&#x7AEF;&#xFF1B;</span>
    rclcpp::init(argc,argv);
    <span class="hljs-comment">// 4.&#x8C03;&#x7528;spin&#x51FD;&#x6570;&#xFF0C;&#x5E76;&#x4F20;&#x5165;&#x8282;&#x70B9;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#xFF1B;</span>
    <span class="hljs-keyword">auto</span> client = <span class="hljs-built_in">std</span>::make_shared&lt;ExeNavActionClient&gt;();

    <span class="hljs-keyword">if</span> (argc != <span class="hljs-number">5</span>)
    {
        RCLCPP_INFO(client-&gt;get_logger(),<span class="hljs-string">&quot;&#x8BF7;&#x4F20;&#x5165;&#x76EE;&#x6807;&#x7684;&#x4F4D;&#x59FF;&#x53C2;&#x6570;:(x,y,theta)&quot;</span>);
        <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
    }
    <span class="hljs-comment">// &#x53D1;&#x9001;&#x76EE;&#x6807;&#x70B9;</span>
    client-&gt;send_goal(atof(argv[<span class="hljs-number">1</span>]), atof(argv[<span class="hljs-number">2</span>]), atof(argv[<span class="hljs-number">3</span>]));
    rclcpp::spin(client);
    <span class="hljs-comment">// 5.&#x91CA;&#x653E;&#x8D44;&#x6E90;&#x3002;</span>
    rclcpp::shutdown();
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h4 id="4launch&#x6587;&#x4EF6;">4.launch&#x6587;&#x4EF6;</h4>
<p>&#x8BE5;&#x6848;&#x4F8B;&#x9700;&#x8981;&#x5206;&#x522B;&#x4E3A;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#x548C;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x521B;&#x5EFA;launch&#x6587;&#x4EF6;&#x3002;</p>
<p>&#x529F;&#x80FD;&#x5305;cpp07_exercise&#x7684;launch&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x9996;&#x5148;&#x65B0;&#x5EFA;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;launch&#x6587;&#x4EF6;exe04_action_server.launch.py&#xFF0C;&#x7F16;&#x8F91;&#x6587;&#x4EF6;&#xFF0C;&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code class="lang-py"><span class="hljs-keyword">from</span> launch <span class="hljs-keyword">import</span> LaunchDescription
<span class="hljs-keyword">from</span> launch_ros.actions <span class="hljs-keyword">import</span> Node

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">generate_launch_description</span><span class="hljs-params">()</span>:</span>
    <span class="hljs-comment"># &#x521B;&#x5EFA;turtlesim_node&#x8282;&#x70B9;</span>
    turtle = Node(package=<span class="hljs-string">&quot;turtlesim&quot;</span>,executable=<span class="hljs-string">&quot;turtlesim_node&quot;</span>)
    <span class="hljs-comment"># &#x521B;&#x5EFA;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#x8282;&#x70B9;</span>
    server = Node(package=<span class="hljs-string">&quot;cpp07_exercise&quot;</span>,executable=<span class="hljs-string">&quot;exe04_action_server&quot;</span>)

    <span class="hljs-keyword">return</span> LaunchDescription([turtle,server])
</code></pre>
<p>&#x7136;&#x540E;&#x65B0;&#x5EFA;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;launch&#x6587;&#x4EF6;exe05_action_client.launch.py&#xFF0C;&#x7F16;&#x8F91;&#x6587;&#x4EF6;&#xFF0C;&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code class="lang-py"><span class="hljs-keyword">from</span> launch <span class="hljs-keyword">import</span> LaunchDescription
<span class="hljs-keyword">from</span> launch_ros.actions <span class="hljs-keyword">import</span> Node
<span class="hljs-keyword">from</span> launch.actions <span class="hljs-keyword">import</span> ExecuteProcess

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">generate_launch_description</span><span class="hljs-params">()</span>:</span>
    <span class="hljs-comment"># &#x8BBE;&#x7F6E;&#x76EE;&#x6807;&#x70B9;&#x7684;&#x5750;&#x6807;&#xFF0C;&#x4EE5;&#x53CA;&#x76EE;&#x6807;&#x70B9;&#x4E4C;&#x9F9F;&#x7684;&#x540D;&#x79F0;</span>
    x = <span class="hljs-number">8.54</span>
    y = <span class="hljs-number">9.54</span>
    theta = <span class="hljs-number">0.0</span>
    name = <span class="hljs-string">&quot;t3&quot;</span>
    <span class="hljs-comment"># &#x751F;&#x6210;&#x65B0;&#x7684;&#x4E4C;&#x9F9F;</span>
    spawn = ExecuteProcess(
        cmd=[<span class="hljs-string">&quot;ros2 service call /spawn turtlesim/srv/Spawn \&quot;{&apos;x&apos;: &quot;</span>
                + str(x) + <span class="hljs-string">&quot;,&apos;y&apos;: &quot;</span> + str(y) + <span class="hljs-string">&quot;,&apos;theta&apos;: &quot;</span> + str(theta) + <span class="hljs-string">&quot;,&apos;name&apos;: &apos;&quot;</span> + name + <span class="hljs-string">&quot;&apos;}\&quot;&quot;</span>],
        <span class="hljs-comment"># output=&quot;both&quot;,</span>
        shell=<span class="hljs-keyword">True</span>
    )
    <span class="hljs-comment"># &#x521B;&#x5EFA;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x8282;&#x70B9;</span>
    client = Node(package=<span class="hljs-string">&quot;cpp07_exercise&quot;</span>,
                executable=<span class="hljs-string">&quot;exe05_action_client&quot;</span>,
                arguments=[str(x),str(y),str(theta)])
    <span class="hljs-keyword">return</span> LaunchDescription([spawn,client])
</code></pre>
<h4 id="5&#x7F16;&#x8F91;&#x914D;&#x7F6E;&#x6587;&#x4EF6;">5.&#x7F16;&#x8F91;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h4>
<p>&#x6B64;&#x5904;&#x9700;&#x8981;&#x7F16;&#x8F91;base_interfaces_demo&#x548C;cpp07_exercise&#x4E24;&#x4E2A;&#x529F;&#x80FD;&#x5305;&#x4E0B;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3002;</p>
<h5 id="1baseinterfacesdemo&#x4E0B;&#x7684;cmakeliststxt">1.base_interfaces_demo&#x4E0B;&#x7684;CMakeLists.txt</h5>
<p>&#x548C;&#x524D;&#x9762;&#x670D;&#x52A1;&#x901A;&#x4FE1;&#x4E00;&#x6837;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x4FEE;&#x6539;CMakeLists.txt&#x4E2D;&#x7684;rosidl_generate_interfaces &#x51FD;&#x6570;&#x5373;&#x53EF;&#xFF0C;&#x4FEE;&#x6539;&#x540E;&#x7684;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>rosidl_generate_interfaces(${PROJECT_NAME}
  &quot;msg/Student.msg&quot;
  &quot;srv/AddInts.srv&quot;
  &quot;srv/Distance.srv&quot;
  &quot;action/Progress.action&quot;
  &quot;action/Nav.action&quot;
)
</code></pre><h5 id="2cpp07exercise&#x4E0B;&#x7684;cmakeliststxt">2.cpp07_exercise&#x4E0B;&#x7684;CMakeLists.txt</h5>
<p>CMakeLists.txt &#x6587;&#x4EF6;&#x9700;&#x8981;&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code>add_executable(exe04_action_server src/exe04_action_server.cpp)
ament_target_dependencies(
  exe04_action_server
  &quot;rclcpp&quot;
  &quot;turtlesim&quot;
  &quot;base_interfaces_demo&quot;
  &quot;geometry_msgs&quot;
  &quot;rclcpp_action&quot;
)

add_executable(exe05_action_client src/exe05_action_client.cpp)
ament_target_dependencies(
  exe05_action_client
  &quot;rclcpp&quot;
  &quot;turtlesim&quot;
  &quot;base_interfaces_demo&quot;
  &quot;geometry_msgs&quot;
  &quot;rclcpp_action&quot;
)
</code></pre><p>&#x6587;&#x4EF6;&#x4E2D; install &#x4FEE;&#x6539;&#x4E3A;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code>install(TARGETS 
  exe01_pub_sub
  exe02_server
  exe03_client
  exe04_action_server
  exe05_action_client  
  DESTINATION lib/${PROJECT_NAME})
</code></pre><h4 id="6&#x7F16;&#x8BD1;">6.&#x7F16;&#x8BD1;</h4>
<p>&#x7EC8;&#x7AEF;&#x4E2D;&#x8FDB;&#x5165;&#x5F53;&#x524D;&#x5DE5;&#x4F5C;&#x7A7A;&#x95F4;&#xFF0C;&#x7F16;&#x8BD1;&#x529F;&#x80FD;&#x5305;&#xFF1A;</p>
<pre><code>colcon build --packages-select base_interfaces_demo cpp07_exercise
</code></pre><h4 id="7&#x6267;&#x884C;">7.&#x6267;&#x884C;</h4>
<p>&#x5F53;&#x524D;&#x5DE5;&#x4F5C;&#x7A7A;&#x95F4;&#x4E0B;&#xFF0C;&#x542F;&#x52A8;&#x4E24;&#x4E2A;&#x7EC8;&#x7AEF;&#x3002;</p>
<p>&#x7EC8;&#x7AEF;1&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x6307;&#x4EE4;&#xFF1A;</p>
<pre><code>. install/setup.bash
ros2 launch cpp07_exercise exe04_action_server.launch.py
</code></pre><p>&#x6307;&#x4EE4;&#x6267;&#x884C;&#x540E;&#xFF0C;&#x5C06;&#x751F;&#x6210;turtlesim_node&#x8282;&#x70B9;&#x5BF9;&#x5E94;&#x7684;&#x7A97;&#x53E3;&#xFF0C;&#x5E76;&#x4E14;&#x4F1A;&#x542F;&#x52A8;&#x4E4C;&#x9F9F;&#x5BFC;&#x822A;&#x7684;&#x52A8;&#x4F5C;&#x670D;&#x52A1;&#x7AEF;&#x3002;</p>
<p>&#x7EC8;&#x7AEF;2&#x8F93;&#x5165;&#x5982;&#x4E0B;&#x6307;&#x4EE4;&#xFF1A;</p>
<pre><code>. install/setup.bash
ros2 launch cpp07_exercise exe05_action_client.launch.py
</code></pre><p>&#x6307;&#x4EE4;&#x6267;&#x884C;&#x540E;&#xFF0C;&#x4F1A;&#x751F;&#x6210;&#x4E00;&#x53EA;&#x65B0;&#x7684;&#x4E4C;&#x9F9F;&#xFF0C;&#x5E76;&#x4E14;&#x539F;&#x751F;&#x4E4C;&#x9F9F;&#x4F1A;&#x4EE5;&#x65B0;&#x4E4C;&#x9F9F;&#x4E3A;&#x76EE;&#x6807;&#x70B9;&#x5411;&#x5176;&#x8FD0;&#x52A8;&#xFF0C;&#x8FD0;&#x52A8;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x52A8;&#x4F5C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x63A5;&#x6536;&#x670D;&#x52A1;&#x7AEF;&#x8FDE;&#x7EED;&#x53CD;&#x9988;&#x7684;&#x5269;&#x4F59;&#x8DDD;&#x79BB;&#x6D88;&#x606F;&#xFF0C;&#x6700;&#x7EC8;&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#x4E0E;&#x6F14;&#x793A;&#x6848;&#x4F8B;&#x7C7B;&#x4F3C;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="385-dong-zuo-tong-xin-an-li-fen-xi.html" class="navigation navigation-prev " aria-label="Previous page: 3.8.5 动作通信案例分析">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="387-can-shu-fu-wu-an-li-fen-xi.html" class="navigation navigation-next " aria-label="Next page: 3.8.7 参数服务案例分析">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.8.6 动作通信实现","level":"1.4.8.6","depth":3,"next":{"title":"3.8.7 参数服务案例分析","level":"1.4.8.7","depth":3,"path":"di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong/38-tong-xin-ji-zhi-lian-xi/387-can-shu-fu-wu-an-li-fen-xi.md","ref":"di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong/38-tong-xin-ji-zhi-lian-xi/387-can-shu-fu-wu-an-li-fen-xi.md","articles":[]},"previous":{"title":"3.8.5 动作通信案例分析","level":"1.4.8.5","depth":3,"path":"di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong/38-tong-xin-ji-zhi-lian-xi/385-dong-zuo-tong-xin-an-li-fen-xi.md","ref":"di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong/38-tong-xin-ji-zhi-lian-xi/385-dong-zuo-tong-xin-an-li-fen-xi.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["expandable-chapters"],"pluginsConfig":{"expandable-chapters":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"di-3-zhang-ros2-tong-xin-ji-zhi-bu-chong/38-tong-xin-ji-zhi-lian-xi/386-dong-zuo-tong-xin-shi-xian.md","mtime":"2022-08-06T10:07:49.026Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-10-07T11:10:49.038Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

